﻿Public Class NhanVien
#Region "Thuoc tinh"
    Private Shared _TenNV As String = ""
    Public Shared Property TenNV As String
        Get
            Return _TenNV
        End Get
        Private Set(ByVal value As String)
            _TenNV = value
        End Set
    End Property
    Private Shared _MaNV As String = ""
    Public Shared Property MaNV As String
        Get
            Return _MaNV
        End Get
        Private Set(ByVal value As String)
            _MaNV = value
        End Set
    End Property
    Private Shared _Quyen As Int64
    Public Shared Property Quyen As Int64
        Get
            Return _Quyen
        End Get
        Private Set(ByVal value As Int64)
            _Quyen = value
        End Set
    End Property
#End Region
    Public Shared Function Them(ByVal tennv As String, ByVal diachi As String, ByVal dienthoai As String, ByVal cmnd As String)
        tennv = EscapeString(tennv)
        diachi = EscapeString(diachi)
        dienthoai = EscapeString(dienthoai)
        cmnd = EscapeString(cmnd)
        Return db.Query("INSERT INTO  NhanVien(TenNV,DiaChi,DienThoai,CMND) VALUES('" + tennv + "','" + diachi + "','" + dienthoai + "','" + cmnd + "'")
    End Function
    Public Shared Function DSNV() As DataTable
        Return db.QueryTable("SELECT * FROM  NhanVien")
    End Function
    Public Shared Function CapNhat(ByVal manv As String, ByVal tennv As String, ByVal ngaysinh As String, ByVal dienthoai As String, ByVal cmnd As String)

    End Function
    Public Shared Function DangNhap(ByVal MaNV As String, ByVal MatKhau As String) As Boolean
        Dim dt As New DataTable
        dt = db.QueryTable("SELECT * FROM NhanVien where MaNV='" & MaNV & "'")
        If dt.Rows.Count <> 1 Then Return False
        If dt.Rows(0)("MatKhau") = MatKhau Then
            _TenNV = dt.Rows(0)("TenNV")
            _MaNV = dt.Rows(0)("MaNV")
            _Quyen = dt.Rows(0)("Quyen")
            Return True
        End If
        Return False
    End Function
    Public Shared Function DaDangNhap() As Boolean
        'MsgBox(MaNV)
        Return (Not MaNV = "")
    End Function
End Class
